<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
    <meta name="author" content="">
    <title></title>
    <% include("../inc/input_css.html"){}%>
    <style>
        label{
            width: 140px!important;
        }
    </style>

    <%
    var isAdd = false;
    var isEdit = false;
    if(isEmpty(deliveryType.id)){
    isAdd = true;
    }else{
    isEdit = true;
    }%>
</head>
<body>
<div class="ibox">
    <div class="ibox-title">
        <div class="pull-left mbx navbar_title">
            <span class="current">商城设置</span>
            <span class="line">/</span>
            <span class="current"><a href="/shop/deliveryType/list">配送方式</a></span><span class="line">/</span>
            <%if(isAdd){%>添加配送方式<%}else{%>编辑配送方式<%}%>
        </div>
    </div>
    <div class="ibox-content">
        <div class="wrapper wrapper-content">
            <div class="row">
                <div class="padding-40">
                    <form class="form-horizontal form-validate" method="post" id="form" action="<%if (isAdd){%>${base}/shop/deliveryType/save<%}else{%>${base}/shop/deliveryType/update<%}%>">
                        <input type="hidden" name="deliveryType.id" value="${deliveryType.id!}" />
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>配送方式名称</label>
                                <div class="col-sm-3">
                                    <input type="text" name="deliveryType.name" id="deliveryTypeName" value="${deliveryType.name!}" class="form-control light-input" required>
                                </div>

                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>配送类型</label>
                                <div class="col-sm-3">
                                    <select name="deliveryMethod" id="deliveryMethod" onchange="changeDelivery()" value="" class="form-control light-input" required>
                                        <option value="">请选择...</option>
                                        <%for(list in allDeliveryMethod){%>
                                            <option value="${list}"<%if (list == deliveryType.deliveryMethodValue!){%> selected <%}%>>
                                                ${i18n("DeliveryMethod." + list)}
                                            </option>
                                        <%}%>
                                    </select>
                                </div>
                            </div>
                            <div class="form-group" id="defaultDeliveryCorp">
                                <label class="col-sm-2 control-label">默认物流公司</label>
                                <div class="col-sm-3">
                                    <select name="deliveryType.defaultDeliveryCorp_id" class="form-control light-input">
                                        <option value="">请选择...</option>
                                        <%for(list in allDeliveryCorp){%>
                                        <option value="${list.id}" <%if (list.id == deliveryType.defaultDeliveryCorp_id!){%>selected <%}%>>
                                        ${list.name}
                                        </option>
                                        <%}%>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group" id="firstWeight">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>首重量</label>
                                <div class="row">
                                    <div class="col-sm-2">
                                        <input type="text" name="deliveryType.firstWeight"  value="${deliveryType.firstWeight!0}" class="form-control light-input" required>
                                    </div>
                                    <div class="col-sm-1" >
                                        <select name="firstWeightUnit" class="form-control light-input">
                                            <%for(list in allWeightUnit){%>
                                            <option value="${list}"<%if (list == deliveryType.firstWeightUnit!){%> selected <%}%>>
                                            ${i18n("WeightUnit." + list)}
                                            </option>
                                            <%}%>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group" id="continueWeight">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>续重量</label>
                                <div class="row">
                                    <div class="col-sm-2">
                                        <input type="text" name="deliveryType.continueWeight"  value="${deliveryType.continueWeight!0}" class="form-control light-input" required="true">
                                    </div>
                                    <div class="col-sm-1" >
                                        <select name="firstWeightUnit" class="form-control light-input">
                                            <%for(list in allWeightUnit){%>
                                            <option value="${list}"<%if (list == deliveryType.continueWeightUnit!){%> selected <%}%>>
                                            ${i18n("WeightUnit." + list)}
                                            </option>
                                            <%}%>
                                        </select>
                                    </div>
                                </div>

                            </div>
                            <div class="form-group" id="firstWeightPrice">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>首重价格</label>
                                <div class="col-sm-3">
                                    <input type="text" name="deliveryType.firstWeightPrice"  value="${deliveryType.firstWeightPrice!0}" class="form-control light-input" required=>
                                </div>

                            </div>
                            <div class="form-group" id="continueWeightPrice">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>首重价格</label>
                                <div class="col-sm-3">
                                    <input type="text" name="deliveryType.continueWeightPrice"  value="${deliveryType.continueWeightPrice!0}" class="form-control light-input" required="true">
                                </div>

                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label"><span class="maroon">*</span>排序</label>
                                <div class="col-sm-3">
                                    <input type="text" name="deliveryType.orderList"  value="${deliveryType.orderList!50}" class="form-control light-input" required="true">
                                </div>

                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">介绍</label>
                                <div class="col-sm-3">
                                    <textarea name="deliveryType.description" rows="8" cols="80" class="form-control light-input">${deliveryType.description!}</textarea>
                                </div>

                            </div>
                        <div class="form-group" style="margin-top: 24px">
                            <label class="col-sm-2 control-label "></label>
                            <div class="col-sm-4 col-sm-offset-0">
                                <button class="hive-btn-cancle" id="btn_cancle" type="button" onclick="history.back()">&nbsp;取消&nbsp;</button>
                                <button class="hive-btn hive-btn-primary margin-left-8" type="submit">&nbsp;提交&nbsp;
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>



</div>
<% include("../inc/input_js.html"){}%>

<!-- 自定义js -->
<script src="/res/js/jquery-migrate-1.2.1.js"></script><!--jquery1.9 以上补丁-->
<script type="text/javascript">
    var uploadUrl="/file/uploadfile?shopId=${shopId!}&type=d";
    var browserUrl="/file/browser?shopId=${shopId!}";
</script>
<script src="https://static.9hive.cn/global/vendor/file/file.js"></script>
<script type="text/javascript">
    $(function () {
        $("input.browserButton").browser();
    })


</script>

<script type="text/javascript">
    function check(){
        var deliveryTypeName=$("#deliveryTypeName").val();
        var firstWeight=$("input[name='deliveryType.firstWeight']").val();//首重量
        var continueWeight=$("input[name='deliveryType.continueWeight']").val();//续重量
        var firstWeightPrice=$("input[name='deliveryType.firstWeightPrice']").val();//首重价格
        var continueWeightPrice=$("input[name='deliveryType.continueWeightPrice']").val();//续重价格
        var deliveryTypeOrderList=$("#deliveryTypeOrderList").val();
        var regNumber=/^[0-9]+(.[0-9]*)?$/;
        var listReg=/^\d*\d*\d+$/;

        if(!deliveryTypeName){
            layer.msg("请填写配送方式名称!");
            return false;
        }
        if(!regNumber.test(firstWeight)){
            layer.msg("首重量只能是大于或等于零的数字!");
            return false;
        }
        if(!regNumber.test(continueWeight)){
            layer.msg('续重量只能是大于或等于零的数字');
            return false;
        }
        if(!regNumber.test(firstWeightPrice)){
            layer.msg('首重价格只能是大于或等于零的数字');
            return false;
        }
        if(!regNumber.test(continueWeightPrice)){
            layer.msg('续重价格只能是大于或等于零的数字');
            return false;
        }
        if(!listReg.test(deliveryTypeOrderList) || parseInt(deliveryTypeOrderList)>999){
            layer.msg("排序请输入0-999的正整数!");
            return false;
        }



    }
    function changeDelivery(){
        var deliveryMethod=$("select[name='deliveryMethod']").val();
        if(deliveryMethod=='selfDelivery'){
            $("#defaultDeliveryCorp").hide();
            $("#firstWeight").hide();
            $("#continueWeight").hide();
            $("#firstWeightPrice").hide();
            $("#continueWeightPrice").hide();
        }else{
            $("#defaultDeliveryCorp").show();
            $("#firstWeight").show();
            $("#continueWeight").show();
            $("#firstWeightPrice").show();
            $("#continueWeightPrice").show();
        }
    }
</script>
</body>
</html>